package com.scau.hwadee.examination.service.impl;

import com.scau.hwadee.examination.entity.UserInfo;
import com.scau.hwadee.examination.mapper.UserInfoMapper;
import com.scau.hwadee.examination.service.UserInfoService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.Map;

/**
 * @author: YHX
 * @Date: 2019/7/10 16:47
 */
@Service
public class UserInfoServiceImpl implements UserInfoService {
    @Autowired
    private UserInfoMapper userInfoMapper;

    @Override
    public String resetPassword(Map<String, Object> map) {
        String userEmail = map.get("userEmail").toString();
        String newPassword = map.get("newPassword").toString();
        UserInfo userInfo = userInfoMapper.getUserByUserEmail(userEmail);
        userInfo.setUserPassword(newPassword);
        int cnt = userInfoMapper.updateUserByPrimaryKey(userInfo);
        if (cnt > 0) {
            return "修改密码成功";
        } else {
            return "修改密码失败";
        }
    }
}
